package chabernac.android.wordbattle.model;

import java.util.List;

public class AllDirectionsSelectionHelper implements iSelectionHelper {

  @Override
  public boolean isSelectionAllowed(WordRaster aRaster,  Letter aNewLetterToSelect) {
    List<Letter> theSelectedLetters = aRaster.getSelectedLetters();
    
    if(!theSelectedLetters.isEmpty()){
      Letter theLastSelectedLetter = theSelectedLetters.get(theSelectedLetters.size() - 1);
      if(Math.abs(theLastSelectedLetter.getColumn() - aNewLetterToSelect.getColumn()) > 1) return false;
      if(Math.abs(theLastSelectedLetter.getRow() - aNewLetterToSelect.getRow()) > 1) return false;
    }
    
    return true;
  }

  @Override
  public boolean isDiagonalSelectionGapNeeded() {
    return true;
  }

}
